import { ApiProperty } from "@nestjs/swagger";
import { IsInt, IsNotEmpty, IsOptional, IsString } from "class-validator";

export class CreateBookDto {
  @ApiProperty({ description: "图书名称" })
  @IsString()
  @IsNotEmpty({ message: "图书名称不能为空" })
  name: string;

  @ApiProperty({ description: "图书作者" })
  @IsString()
  @IsNotEmpty({ message: "缺少图书作者信息" })
  author?: string;

  @ApiProperty({ description: "图书描述" })
  @IsOptional()
  @IsString()
  desc?: string;

  @ApiProperty({ description: "图书价格" })
  @IsOptional()
  @IsInt()
  price?: number;
}

export class UpdateBookDto {
  @IsString()
  name?: string;
  @IsString()
  author?: string;
  @IsString()
  desc?: string;
}
